#!/bin/bash

db_date=$2
echo $db_date
db_name=enterprise_employee

import_data() {
/home/software/sqoop-1.4.7/bin/sqoop import \
--connect jdbc:mysql://192.168.1.90:3306/$db_name \
--username changyuan \
--password tecsunBD@2020 \
--target-dir /origin_data/db/$1/$db_date \
--delete-target-dir \
--num-mappers 1 \
--null-string '\\N' \
--null-non-string '\\N' \
--fields-terminated-by ";" \
--query "$2"' and $CONDITIONS;'
}

import_enterprise(){
  import_data "enterprise" "select * from enterprise where 1=1"
}

import_enterprise_business(){
  import_data "enterprise_business" "select * from enterprise_business where 1=1"
}

import_enterprise_person_info(){
  import_data "enterprise_person_info" "select * from enterprise_person_info where 1=1"
}

import_job_fair(){
  import_data "job_fair" "select * from job_fair where 1=1"
}

import_position(){
  import_data "position" "select * from position where 1=1"
}


case $1 in
   "all")
   import_enterprise
   import_enterprise_business
   import_enterprise_person_info
   import_job_fair
   import_position
  ;;
esac